import request from '@/utils/request'

// 创建物品类型
export function createGoodsType(data) {
  return request({
    url: `/v1/goods/type`,
    method: 'POST',
    data
  })
}

// 修改物品类型
export function editGoodsType(data) {
  return request({
    url: `/v1/goods/type/edit`,
    method: 'POST',
    data
  })
}

// 删除物品类型
export function deleteGoodsType(params) {
  return request({
    url: `/v1/goods/type`,
    method: 'DELETE',
    params
  })
}

// 获取物品类型
export function getGoodsType(params) {
  return request({
    url: `/v1/goods/type`,
    method: 'GET',
    params
  })
}

// 获取物品类型详情
export function getGoodsTypeDetails(id) {
  return request({
    url: `/v1/goods/type/${id}`,
    method: 'GET'
  })
}

// 物品录入
export function createWarehouseWarrant(data) {
  return request({
    url: `/v1/goods/put`,
    method: 'POST',
    data
  })
}

// 修改物品信息
export function editWarehouseWarrant(data) {
  return request({
    url: `/v1/goods/put/edit`,
    method: 'POST',
    data
  })
}

// 删除物品
export function deleteWarehouseWarrant(id) {
  return request({
    url: `/v1/goods/put/${id}`,
    method: 'DELETE'
  })
}

// 获取物品列表
export function getWarehouseWarrantList(params) {
  return request({
    url: `/v1/goods/put`,
    method: 'GET',
    params
  })
}

// 获取物品详情
export function getWarehouseWarrantDetails(id) {
  return request({
    url: `/v1/goods/put/${id}`,
    method: 'GET'
  })
}

// 获取库存信息
export function getInventoryInfo(params) {
  return request({
    url: `/v1/goods/inventory`,
    method: 'GET',
    params
  })
}

// 获取库存详情
export function getInventoryDetails(id) {
  return request({
    url: `/v1/goods/inventory/${id}`,
    method: 'GET'
  })
}

// 获取库存变更记录
export function getInventoryChangeRecord(params) {
  return request({
    url: `/v1/goods/inventory/records`,
    method: 'GET',
    params
  })
}

// 获取库存变更类型
export function getInventoryRecordType() {
  return request({
    url: `/v1/goods/inventory/records/type`,
    method: 'GET'
  })
}

// 删除物品辅助单位
export function removeGoodsTypeUnit(params) {
  return request({
    url: `/v1/goods/type/unit`,
    method: 'DELETE',
    params
  })
}

// 创建库存调整单
export function createInventoryAdjust(data) {
  return request({
    url: `/v1/goods/adjust/inventory`,
    method: 'POST',
    data
  })
}

// 审核库存调整单
export function examineInventoryAdjust(params) {
  return request({
    url: `/v1/goods/adjust/inventory`,
    method: 'PUT',
    params
  })
}

// 获取库存调整单
export function getInventoryAdjustRecords(params) {
  return request({
    url: `/v1/goods/adjust/inventory`,
    method: 'GET',
    params
  })
}

// 创建出库申请
export function createStockOut(data) {
  return request({
    url: `/v1/goods/out`,
    method: 'POST',
    data
  })
}

// 修改出库申请
export function editStockOut(data) {
  return request({
    url: `/v1/goods/out/edit`,
    method: 'POST',
    data
  })
}

// 审核出库申请
export function examineStockOut(data) {
  return request({
    url: `/v1/goods/out/examine`,
    method: 'POST',
    data
  })
}

// 获取出库申请记录
export function getStockOutRecords(params) {
  return request({
    url: `/v1/goods/out`,
    method: 'GET',
    params
  })
}

// 修改库存调整单
export function editInventoryAdjustRecord(data) {
  return request({
    url: `/v1/goods/adjust/inventory/edit`,
    method: 'POST',
    data
  })
}

// ----------------------------- New -----------------------------------

// 库存信息获取
export function getGoodsList(params) {
  return request({
    url: `/v1/goods`,
    method: 'GET',
    params
  })
}

// 新增出入库记录
export function createInAndOutRecord(data) {
  return request({
    url: `/v1/goods/entrance/library`,
    method: 'POST',
    data
  })
}

// 获取出入库记录
export function getInAndOutRecords(params) {
  return request({
    url: '/v1/goods/entrance/library/list',
    method: 'GET',
    params
  })
}

// 出库审核
export function examineStockOutRecord(data) {
  return request({
    url: `/v1/goods/examine`,
    method: 'PUT',
    data
  })
}

